#ifndef __STEPPER_H
#define __STEPPER_H

#include "stm32f10x.h"
#include "stm32f10x_gpio.h"
#include "stm32f10x_rcc.h"
#include "Delay.h"  // 包含延时函数头文件

// 电机选择枚举
typedef enum {
    MOTOR_A = 0,
    MOTOR_B = 1
} MotorSelect_t;

// 电机A控制引脚定义（PB5~PB8分别接ULN2003的IN1~IN4）
#define MOTOR_A_GPIO GPIOB
#define MOTOR_A_PIN1 GPIO_Pin_5
#define MOTOR_A_PIN2 GPIO_Pin_6
#define MOTOR_A_PIN3 GPIO_Pin_7
#define MOTOR_A_PIN4 GPIO_Pin_8

// 电机B控制引脚定义（PA0~PA3分别接ULN2003的IN1~IN4）
#define MOTOR_B_GPIO GPIOA
#define MOTOR_B_PIN1 GPIO_Pin_0
#define MOTOR_B_PIN2 GPIO_Pin_1
#define MOTOR_B_PIN3 GPIO_Pin_2
#define MOTOR_B_PIN4 GPIO_Pin_3

// 步进电机状态定义
typedef enum {
    STEPPER_STOP = 0,
    STEPPER_FORWARD = 1,
    STEPPER_BACKWARD = 2
} StepperState_t;

// 函数声明
void Stepper_Init(void);
void Stepper_Step(MotorSelect_t motor, int step);
void Stepper_Forward(MotorSelect_t motor, uint32_t speed);
void Stepper_Backward(MotorSelect_t motor, uint32_t speed);
void Stepper_SetState(MotorSelect_t motor, StepperState_t state, uint32_t speed);
void Stepper_Stop(MotorSelect_t motor);
void Stepper_Process(MotorSelect_t motor);
void Stepper_Forward360(MotorSelect_t motor, uint32_t speed);
void Stepper_Backward360(MotorSelect_t motor, uint32_t speed);
void Stepper_ForwardAngle(MotorSelect_t motor, uint32_t angle, uint32_t speed);
void Stepper_BackwardAngle(MotorSelect_t motor, uint32_t angle, uint32_t speed);

#endif 
